home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2.sit / Raven 1.2 / Source / Foundation / Common / ZStringUtils.h < prev    next >
Text File  |  1997-08-07  |  3KB  |  86 lines

  1. /*
  2.  *  File:       ZStringUtils.h
  3.  *  Summary:       Misc string utilities
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996-1997 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <3>     8/05/97    JDJ        Added LoadAppString and LoadRavenString.
  12.  *         <2>     7/27/97    JDJ        Added StripTrailing.
  13.  *         <1>     8/09/96    JDJ        Created (from ZMiscUtils)
  14.  */
  15.  
  16. #pragma once
  17.  
  18. #include <String>
  19.  
  20. #include <ZConstants.h>
  21. #include <ZTypes.h>
  22.  
  23.  
  24. // ===================================================================================
  25. //    Conversions
  26. // ===================================================================================
  27. string         PStrToStr(const unsigned char* pStr);
  28.  
  29. unsigned char* StrToPStr(const string& cStr);
  30.  
  31. const char*    IDToStr(IDType id);
  32.  
  33. IDType        StrToID(const string& str);        
  34.  
  35.  
  36. // ===================================================================================
  37. //    Loading
  38. // ===================================================================================
  39. string        LoadString(ResID id);
  40.  
  41. string        LoadIndString(ResID strList, int index);
  42.             // 1-based!
  43.  
  44. string         LookUpString(ResID id, int code);
  45.             // Returns the string corresponding to code in a STRX resource (or "" if code
  46.             // isn't found). This is used by ReportError to map error codes to strings.
  47.             
  48. string         LoadAppString(const string& str);
  49.             // Looks up str using 'StrM' resource 256. If the string or the resource
  50.             // is missing the input string is returned. This is the preferred way to
  51.             // use strings in Raven apps.
  52.  
  53. string         LoadRavenString(const string& str);
  54.             // Like LoadAppString except that 'StrM' resource 128 is used.
  55.  
  56.  
  57. // ===================================================================================
  58. //    Disassembly
  59. // ===================================================================================
  60. string         Before(const string& str, const string& subStr);
  61.             // Returns the string before subStr or an empty string if subStr isn't found.
  62.  
  63. string         After(const string& str, const string& subStr);
  64.             // Returns the string after subStr or an empty string if subStr isn't found.
  65.  
  66. string         Parse(string& str, const string& term);
  67.             // Removes and returns next word in str. Word is char run not in term. 
  68.             // When the last word is returned str will be empty.
  69.             
  70.  
  71. // ===================================================================================
  72. //    Misc
  73. // ===================================================================================
  74. string        StrToUpperStr(const string& lowerStr);
  75.  
  76. string        StrToLowerStr(const string& upperStr);
  77.  
  78. string         Strip(const string& str, const string& padding = " ");
  79.             // Removes characters in pad from the start of str.
  80.  
  81. string         StripTrailing(const string& str, const string& padding = " ");
  82.             // Removes characters in pad from the end of str.
  83.  
  84. string         Replace(const string& str, char oldCh, char newCh);
  85.  
  86.